package cn.topkinson.rabbitmq.dead.queue.controller;

import cn.topkinson.rabbitmq.dead.queue.config.RabbitConfig;
import cn.topkinson.rabbitmq.dead.queue.service.MsgService;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author huangzihao
 * @Date 2020/12/26 19:45
 */
@RestController
public class MsgController {

    @Autowired
    private MsgService msgService;

    @Autowired
    private AmqpTemplate amqpTemplate;

    //http://127.0.0.1:8567/dlx/pay
    @RequestMapping("/pay")
    public String pay() {
        //执行支付，完成消息的消费
        String orderNo = (String) amqpTemplate.receiveAndConvert(RabbitConfig.Q_PAY);
        System.out.println("主动完成支付：订单号："+orderNo);
        return orderNo;
    }



}
